public class Test9 {
    public static int getElement(int[] array, int index)throws ArrayIndexOutOfBoundsException{
        if(index < 0 || index >= array.length){
            throw new ArrayIndexOutOfBoundsException("传递的数组下标越界");
        }
        return array[index];
    }


    public static void main(String[] args) {
        int[] array1 = {1,2,3};
        //getElement(array1,3);



        int[] arr2 = {1,2,3,4};


        try{
            int[] arr1 = null;
            System.out.println(arr1.length);
        }catch (NullPointerException e){
           e.printStackTrace();
        }finally {
            System.out.println("此处代码一定会运行");
        }

        System.out.println("继续执行");

        //int[] arr = {1,2,3};
        //System.out.println(arr[5]);

        //System.out.println(10/0);
    }
}
